<?php
session_start();


ini_set('display_errors', 'On');
error_reporting(E_ALL);


// Connect to the DB.
require_once 'include/config.lib.php';
require_once 'include/database.lib.php';

$_SESSION["previouspage"] = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];//remember the url of this page, used for redirect.

ConnectToDB();// Connect to the DB.

// Load summary data about the paper.
$summaryReq = DBExecute('SELECT * FROM
												 (SELECT COUNT(id) AS resourcecount FROM resource),
												 (SELECT COUNT(id) AS personcount FROM person),
												 (SELECT COUNT(DISTINCT resourceid) AS reviewcount FROM rateresource)');
$summary = $summaryReq->fetchAssocRow();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="third_party/jquery-ui-1.8.5/jquery-ui-1.8.5.custom.css" />
<link rel="stylesheet" type="text/css" href="css/template.css" />
<link rel="stylesheet" type="text/css" href="css/home.css" />
<script type="text/javascript" src="js/system.js"></script>
<script type="text/javascript" src="third_party/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="third_party/jquery-ui-1.8.5/jquery-ui-1.8.5.custom.min.js"></script>
<script type="text/javascript" src="third_party/jquery.tmpl.min.js"></script>
<script id="list-template" type="text/x-jquery-tmpl"> 
<li><a href="paper_view.php?id=${ID}">${TITLE}</a>&nbsp;(${COUNT})</li>
</script>
<script id="paper-result-template" type="text/x-jquery-tmpl"> 
<li>
	<small class="right">resources: ${RES_COUNT}<br />views: ${READ_COUNT}<br />reviews: ${RATE_COUNT}</small>
	<a href="paper_view.php?id=${ID}">${TITLE}</a>
	<p>${ABSTRACT}</p>
	<span>${URL}</span>
</li>
</script>
<script id="person-result-template" type="text/x-jquery-tmpl"> 
<li>
	<a href="person_view.php?id=${ID}">${NAME}</a>
	<p>${DESCRIPTION}</p>
	<span>${EMAIL}</span>
</li>
</script>
<script type="text/javascript">
function SubmitForm(form) {
	RequestData("search.php", $(form).serialize(), UpdateResult);
}

function UpdateResult(data) {
	var template = "#" + data["type"] + "-result-template";
	$("#result-log").text(data["type"] + " search: " + data["count"] + " result(s) (" + data["time"] + " seconds)");
	$("#result").empty();
	$(template).tmpl(data["result"]).appendTo("#result");
}

$(function() {
	$("input.date").datepicker();
	$("#tabs").tabs();
	$("input.button").button();
	RequestData("search.php", { type: "paper", preset: "read" },
							function(data) { $("#list-template").tmpl(data["result"]).appendTo("#most-read-papers"); });
	RequestData("search.php", { type: "paper", preset: "rated" },
							function(data) { $("#list-template").tmpl(data["result"]).appendTo("#most-rated-papers"); });
	RequestData("search.php", { type: "paper", preset: "annotated" },
							function(data) { $("#list-template").tmpl(data["result"]).appendTo("#most-annotated-papers"); });
	
	RequestData("search.php", { type: "paper", preset: "highrated" },
							function(data) { $("#list-template").tmpl(data["result"]).appendTo("#highest-rated-papers"); });
});
</script>
<title>CoRAL Home</title>
</head>

<body>
<?php //to determine whether a user has logged in or not, which will output different buttons
if(isset($_SESSION["accountNo"]))	{	$inorout = "controller/logout.php";	$display = "Log out";}
else	{	$inorout = "login.php";	$display = "Log in";}
?>


<div id="body-wrapper">
<?php include_once 'static/header.php'; ?>
<div id="body">

	<!-- START SECTION: summary -->
	<!-- div id="summary-section" class="section">  -->	
		<table id="summary" class="info"> 
			<tr><td><span>

			<fieldset>			
			<legend id="mainlegend">What is CoRAL?</legend> 
			<div id="homeinfo">
			CoRAL (Collaborative Review Analysis of Literature) is a project aimed to support and to analyze collaborative review of research literature in science. 
			CoRAL supports collaborative review by providing a 
			multi-format document browser which enables users to create and share annotations (the CoRAL browser). Annotations can support commenting, discussing, tagging, 
			and highlighting. It also supports both analysis and reviewing by generating visualized reports about how users collaborate and how researchers show attention 
			to various pieces of literature (CoRAL reporter). In addition, CoRAL connects researchers to each other, not only through discussing and sharing annotations, 
			but also by providing a CoRAL friendship network and linking to other interesting networks such as LinkedIn and Facebook.
			</div>
			</fieldset> 
			<br />
			<fieldset>
			<legend id="mainlegend">CoRAL components</legend>
			<div id="homeinfo">
			<b>CoRAL</b> consists of two components: the 
			<a href="http://www.ualberta.ca/~samaneh/coral-browser.rar"><b>CoRAL browser</b></a> and the <b>CoRAL reporter</b>. <b>CoRAL browser</b> is a desktop application built upon 
			Fab4Browser, specializing it to CoRAL needs such as adding tagging, rating, bibliographic information, and specific server 
			and API use. <b>CoRAL browser</b> connects to the <b>CoRAL server</b> which stores usage data in a proper architecture needed for the <b>CoRAL reporter</b> to 
			reach its goals. <b>CoRAL reporter</b> is a web-based application showing interesting and useful reports about how researchers collaborate, what are interesting 
			papers and what parts of papers attract more attention, how review activities evolve through time, and much more things that you can experience by yourself! CoRAL reporter is 
			in fact this web site that you are viewing!
			</div>
			
			</fieldset> 
			<br />
			<fieldset>
			<legend id="mainlegend">How can you benefit from CoRAL?</legend>
			<div id="homeinfo">
			<b> If you are a student or new to the research world, </b> you can use <b>CoRAL</b> to find out which papers in your field are attracting other researchers to 
			themselves mostly, this way you can start finding important papers faster. You 
			can take benefit of other users' ratings and tags to get more personalized search results and have the most effective papers at top of your search results. If 
			you want to quickly grasp what is paper about, what are the important parts, and is it really talking about what you are looking for, you can take a quick look 
			at other readers' comments and highlights. You can also get to know active researchers in your field and build your network with researchers outside your school.
			</div>			
			
			<div id="homeinfo">
			<b> If you are a researcher or a professional, </b> you will have the opportunity to know researchers in your fields who you didn't have the chance to find them in 
			conferences and other academic environments. You can discuss and criticize literature in your field and easily reach to new ideas being shared 
			in the context of literature. You can also see how your own papers are reviewed by others and how you can improve them and become more effective in your community.
			</div>
			</fieldset>
			<br />
			
			</span></td>
			<td>
				<!-- START SECTION: sidebar -->
				
	<div id="sidebar-section" class="section">
	
		<fieldset style="margin-top: 5px;">
		<legend style="margin-bottom: 5px;">Reviewing Statistics</legend>
		<div><h3>Most Read Papers</h3><ul id="most-read-papers"></ul></div>
		<div><h3>Most Annotated Papers</h3><ul id="most-annotated-papers"></ul></div>
		
		<div><h3>Highest Rated Papers</h3><ul id="highest-rated-papers"></ul></div>
		
<!--		<div><h3>Most Rated Papers</h3><ul id="most-rated-papers"></ul></div>-->
		
		
		</fieldset>
		
	</div>
	<!-- END SECTION: sidebar -->
			</td>
			</tr>
		</table>
		
	
	<!-- /div>  -->
	<!-- END SECTION: summary -->

</div>

<?php include_once 'static/footer.html'; ?>
</div>
</body>
</html>
